/**
 * @Company: 北京慧点科技有限公司 | www.smartdot.com.cn
 * @Copyright 1998-2020 © Smartdot Technologies Co., Ltd.
 */
package com.springlearn.zhoufei.other.spring.demo3;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

@Configurable // 相当于Bean2.xml
public class HelloEvent2_C {

    @Bean
    public HelloEvent2_L1 HelloEvent2_L1() {
        return new HelloEvent2_L1();
    }
    @Bean
    public HelloEvent2Publisher HelloEvent2Publisher() {
        return new HelloEvent2Publisher();
    }
    public static void main(String[] args) {
        // 当实例化上下文时，不需要同时指定HelloWorld8_1.class和HelloWorld6_1.class，只有HelloWorld9类需要提供
        ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(HelloEvent2_C.class);


        HelloEvent2Publisher cvp =
                (HelloEvent2Publisher) context.getBean("HelloEvent2Publisher");
        cvp.publish();
    }
}